<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>隐式类型转换</title>
</head>
<body>
    <!-- 
    string与number做运算
    加法 = 字符串拼接（记住之）
    减乘除 = 数学运算（推理之）
    if(value){...}value会被隐式转布尔
     -->
    <script>
        // 字符串做number减乘除运算 string隐式地转换为number
        console.log("12","12"*2);
        console.log(34 - "12");//22
        console.log(24 / "12");//2

        // 字符串做加法运算 相当于拼接字符串
        console.log("12"+"34");//1234

        // number在与string做加法时 number隐式地转换为string
        console.log(12 + "34");

        /* parseInt/parseFloat/number.toFixed(n) */
        // 字符串隐式转number
        console.log(parseInt("123.45"));//123
        console.log(parseFloat("123.45"));//123.45

        // number隐式转string
        var num = 123.456789
        console.log(num.toFixed(2));//'123.46'

    </script>
</body>
</html>